package com.jic.market.impl.overlay;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.market.entity.overlay.OverlayGroupInfo;
import com.jic.market.mapper.overlay.OverlayGroupInfoMapper;
import com.jic.market.service.overlay.OverlayGroupInfoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 叠加规则组信息表
 *
 * @author : seven
 * @version : v1.0.0
 * @email : 774329481@qq.com
 * @since : 2020-03-20 04:47:43
 */
@Service
public class OverlayGroupInfoServiceImpl implements OverlayGroupInfoService {

    @Autowired
    private OverlayGroupInfoMapper overlayGroupInfoMapper;

    @Override
    public long insert(OverlayGroupInfo overlayGroupInfo) {
        long flag = overlayGroupInfoMapper.insert(overlayGroupInfo);
        return flag;
    }

    @Override
    public long delete(String id) {
        return overlayGroupInfoMapper.delete(id);
    }

    @Override
    public long update(OverlayGroupInfo overlayGroupInfo) {
        return overlayGroupInfoMapper.update(overlayGroupInfo);
    }

    @Override
    public OverlayGroupInfo queryByPrimaryKey(Long id) {
        return overlayGroupInfoMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<OverlayGroupInfo> query(OverlayGroupInfo overlayGroupInfo) {
        return overlayGroupInfoMapper.query(overlayGroupInfo);
    }

    @Override
    public PageResult<OverlayGroupInfo> queryPage(OverlayGroupInfo overlayGroupInfo, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<OverlayGroupInfo> list = overlayGroupInfoMapper.queryPage(startIndex, pageQuery.getLimit(), overlayGroupInfo);
        long count = overlayGroupInfoMapper.queryPageCount(overlayGroupInfo);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}